package com.xuecheng.content.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @Author 12441
 * @Date 2022/9/21 16:29
 * @Version 1.0
 */
//消息发送之前不会触发
@Configuration
public class MQConfiguration {
    //1.创建队列
    @Bean
    public Queue contentQueue() {
        return new Queue("content.queue");
    }
    @Bean
    public TopicExchange contentExchange() {
        return new TopicExchange("content.exchange");
    }
    //完成绑定 队列绑定交换机 设置routingKey为‘course.pub’
    @Bean
    public Binding bindingContentQueue(Queue contentQueue,TopicExchange contentExchange) {
        return BindingBuilder.bind(contentQueue).to(contentExchange).with("course.pub");
    }
}
